All Questions
5 questions
0votes
0answers
71views
State Pattern: Changing object behavior based on more than one field and consistency between their values and state value
I'm Trying to learn about State Pattern. In most of State Pattern examples that I have seen, methods of class change their behavior based on just one field (I mean before applying State Pattern and I'...
1vote
1answer
260views
Could this be considered a valid State GoF Pattern implementation?
For teaching purpose, I would like to create a simple implementation of State Pattern using PHP 7.4. So, I've tried to create a simple "document state machine" starting with Draft, sending to review ...
3votes
2answers
595views
Syntactic characterisation of intrinsic and extrinsic states
Gang of Four’s Flyweight design pattern introduces the concept of intrinsic and extrinsic states: The key concept here is the distinction between intrinsic and extrinsic state. Intrinsic state is ...
2votes
2answers
2kviews
State Design Pattern
I've come across the following State Design Pattern which seems extremely logical and simple to implement: class CeilingFanPullChain { private State m_current_state; public ...
18votes
2answers
1kviews
Is it a good idea to define one big private function in a class to maintain valid state, that is, to update the object's data members?
Although in the code below a simple single item purchase in an e-commerce site is used, my general question is about updating all data members to keep an object's data in valid state at all times. I ...